# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Tercio Martins <echo dGVyY2lvd2VuZGVsQGdtYWlsLmNvbQo= | base64 -d>
# Contributor: Brandon Mulcahy <brandon@jangler.info>

pkgname=schismtracker
pkgver=20221201
pkgrel=1
pkgdesc='An old-school sample-based music composition tool'
arch=('loong64' 'x86_64')
url='https://schismtracker.org'
license=('GPL2')
depends=(
  'libx11'
  'libxv'
  'sdl2'
  'hicolor-icon-theme'
)
makedepends=('git' 'python')
_commit='2bb0ae70a124f60793717e511f140e9e6eaa9d86'
source=("$pkgname::git+https://github.com/schismtracker/schismtracker#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags
}

prepare() {
  cd "$pkgname"

  # modify desktop file & application icon
  sed -e 's/schism.desktop/schismtracker.desktop/' -i Makefile.am
  sed -e 's/schism-icon-128/schismtracker/' -i sys/fd.org/schism.desktop
  mv sys/fd.org/{schism,schismtracker}.desktop
}

build() {
  cd "$pkgname"

  autoreconf -vfi

  ./configure --prefix=/usr

  make
}

package() {
  cd "$pkgname"

  make DESTDIR="$pkgdir" install

  # delete old application icon
  rm -rf "$pkgdir/usr/share/pixmaps"

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" docs/configuration.md README.md

  # application icons
  for i in 16 22 24 32 36 48 64 72 96 128 192; do
    install -vDm644 "icons/schism-icon-${i}.png" "$pkgdir/usr/share/icons/hicolor/${i}x${i}/apps/$pkgname.png" 
  done
  install -vDm644 icons/schism-icon.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
}
